package cn.dhn_app.horseman_app.controller;

import cn.dhn_app.horseman_app.service.HorsemanOrderService;
import cn.itcast.util.ResponseEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author lyy
 * @Description TODO
 * @PACKAGE_NAME: cn.dhn_app.horseman_app.controller
 * @ClassName HorsemanOrder
 * @Date 2020/8/27 17:02
 * @DAY_NAME_FULL: 星期四
 * @Version 1.0
 **/
@Slf4j
@RestController
@RequestMapping(value = "/dhn/order",produces = "application/json;charset=UTF-8")
public class HorsemanOrderController {

    @Resource
    private HorsemanOrderService horsemanOrderService;

    /**
     * 功能描述: <br>
     * 〈根据订单状态查询骑手订单数据〉
     * @Author: lyy
     * @Date: 2020/8/29 18:35
     * @Param: [token, openId, status]
     * @Return: cn.itcast.util.ResponseEntity
     */
    @RequestMapping(value = "/All")
    public ResponseEntity findHorsemanOrderAll(@RequestHeader(value = "token")String token,
                                                @RequestBody Map<String,String> map){
        log.info("开始查询骑手订单数据~~~~~~~");

        String openId = map.get("openId");

        String status = map.get("status");

        return horsemanOrderService.FindAllOrderAndStatus(token, openId,status);
    }

    /**
     * 功能描述: <br>
     * 〈修改订单状态〉
     * @Author: lyy
     * @Date: 2020/10/14 17:07
     * @Param: [token, map]
     * @Return: cn.itcast.util.ResponseEntity
     */
    @RequestMapping(value = "/modify")
    public ResponseEntity updHorsemanOrder(@RequestHeader(value = "token")String token,
                                           @RequestBody Map<String,String> map){
        log.info("开始修改订单状态~~~~~~~");

        String openId = map.get("openId");  //骑手openId

        Integer orderId = Integer.valueOf(map.get("orderId")); //订单Id

        String status = map.get("status"); //状态

        return horsemanOrderService.updHorsemanOrderAndStatus(token,openId,orderId,status);
    }

}
